﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace jnxc.Web.ecshop
{
    public partial class index :shoppage
    {
        BLL.myplant myp = new BLL.myplant();
        BLL.myharmful myh = new BLL.myharmful();
        BLL.product mypro = new BLL.product();
        BLL.nnews news = new BLL.nnews();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //string pro=getP();
                string pro = "山东省";
                DataSet ds;// = myp.GetList(6, "province='" + pro + "'", "pbm");
                //rptplant.DataSource = ds.Tables[0];
                //rptplant.DataBind();
                //ds = myp.GetListT("province='" + pro + "'");
                //rptps.DataSource = ds.Tables[0];
                //rptps.DataBind();
                ds = myh.GetList(6, "province='" + pro + "'", "hbm");
                rptharm.DataSource = ds.Tables[0];
                rptharm.DataBind();
                ds = myh.GetListT("province='" + pro + "'");
                rpths.DataSource = ds.Tables[0];
                rpths.DataBind();
                ds = mypro.GetListV(6, "pcname='物理防治'", "pid desc");
                rpt1.DataSource = ds.Tables[0];
                rpt1.DataBind();
                ds = mypro.GetListV(6, "", "pdatetime desc");
                rptnew.DataSource = ds.Tables[0];
                rptnew.DataBind();
                ds = mypro.GetListV(6, "pcname='生物防治'", "pid desc");
                rpt2.DataSource = ds.Tables[0];
                rpt2.DataBind();
                ds = mypro.GetListV(6, "pcname='化学防治'", "pid desc");
                rpt3.DataSource = ds.Tables[0];
                rpt3.DataBind();
                ds = news.GetList(6, "ntype='公告'", "ntime desc");
                rptgg.DataSource = ds.Tables[0];
                rptgg.DataBind();
                ds = news.GetList(6, "ntype='安全'", "ntime desc");
                rptaq.DataSource = ds.Tables[0];
                rptaq.DataBind();
            }

        }

        protected void rptps_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //rptps_list
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rptps_list") as Repeater;
                DataRowView rowv = (DataRowView)e.Item.DataItem;                
                string ppname = rowv["ppname"].ToString();
                string province = rowv["province"].ToString();                
                rep.DataSource = myp.GetListTV(string.Format("ppname='{0}' and province='{1}'",ppname,province));
                rep.DataBind();
            }

        }

        protected void rpths_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rpths_list") as Repeater;
                DataRowView rowv = (DataRowView)e.Item.DataItem;
                string ppname = rowv["phname"].ToString();
                string province = rowv["province"].ToString();
                rep.DataSource = myh.GetListTV(string.Format("phname='{0}' and province='{1}'", ppname, province));
                rep.DataBind();
            }

        }
    }
}